Skip to content

Leetcode reverse linked list#5

Open
Igneaalis wants to merge 3 commits intomasterfrom
LEETCODE-linked-list
Open

Leetcode reverse linked list#5
Igneaalis wants to merge 3 commits intomasterfrom
LEETCODE-linked-list

Conversation

@Igneaalis
Copy link
Copy Markdown
Owner

No description provided.

@Igneaalis Igneaalis requested a review from Vivelapaix May 13, 2020 17:54
linked-list.md Outdated
:rtype: ListNode
"""

if head and head.next:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь это не нужно

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Но это не критично. Условие проверяется за O(1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда можно вставить еще 10000000000 if, что тоже не критично ? Как изменится быстродействие программы?

Copy link
Copy Markdown
Owner Author

@Igneaalis Igneaalis May 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Условие здесь необходимо, потому что если входные данные: [], то получаем ошибку:

AttributeError: 'NoneType' object has no attribute 'next'
    if head.next:
Line 13 in reverseList (Solution.py)
    ret = Solution().reverseList(param_1)
Line 45 in _driver (Solution.py)
    _driver()
Line 55 in <module> (Solution.py)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Теперь ты убедился, что в условии нет необходимости

Copy link
Copy Markdown

@Vivelapaix Vivelapaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Теперь с именованием порядок.

Надеюсь, это не с моего гитхаба взято за основу, но даже в таком случае, нет ничего плохого :)

@Igneaalis Igneaalis changed the title Linked list LEETCODE Leetcode reverse linked list Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants